#ifndef STACKTP_H_
#define STACKTP_H_

template <class T>
class Stack
{
private:
    enum {MAX = 10};
    T items[MAX];
    int max;
    int top;
public:
    Stack(int size=MAX): max(size),top(0) { T items[size]; }
    bool isempty() const { return top == 0; }
    bool isfull() const {return top == MAX; }
    int length() const {return max;}
    int size() const {return top;}
    void show() const {std::cout << "Stack on " << top <<" in max "<<max<< std::endl;}
    bool push(const T &item); // add
    bool pop(T &item); // remove,pop to item
};

template<class T>
bool Stack<T>::push(const T &item) // add
{
    if(top >= max)
        return false;
    else{
        top++;
        items[top]=item;
        return true;
    }
}

template<class T>
bool Stack<T>::pop(T &item) // add
{
    if(top <= 0)
        return false;
    else{
        item = items[top];
        top--;
        return true;
    }
}
#endif
